﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using RssReader.Resources;
using RssReader.ViewModel;

namespace RssReader
{
    public partial class MainPage : PhoneApplicationPage
    {
        MainViewModel MyVM = new MainViewModel();
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            
            DataContext = MyVM;
            AddrBook.ItemsSource = MyVM.entry;
            

            // Sample code to localize the ApplicationBar
            //BuildLocalizedApplicationBar();
        }

        private void MainLongListSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (AddrBook.SelectedItem == null)
            {
                return;
            }
            NavigationService.Navigate(new Uri("/Detail.xaml?detail=" + Htmlrmover.StripSpaceCharArray((AddrBook.SelectedItem as Entry).content.__html), UriKind.Relative));

        }

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            MessageBox.Show("এটি একটি উইন্ডোজ ফোন আরএসএস রিডার অ্যাপ টেমপ্লেট। \n আরএসএস সোর্স হিসেবে এইখানে ব্যবহার করা হয়েছে Collected Notes and Discussion \nনামে একটি ফেসবুক পেইজের আরএসএস");
        }

        //private void add_Click(object sender, RoutedEventArgs e)
        //{
        //    Entry newEntry = new Entry();
        //    newEntry.title = enterTitle.Text;
        //    newEntry.summary = enterSummery.Text;
        //    //newEntry.content.__html = "just test";
        //    MyVM.entry.Add(newEntry);
        //}

        // Sample code for building a localized ApplicationBar
        //private void BuildLocalizedApplicationBar()
        //{
        //    // Set the page's ApplicationBar to a new instance of ApplicationBar.
        //    ApplicationBar = new ApplicationBar();

        //    // Create a new button and set the text value to the localized string from AppResources.
        //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
        //    appBarButton.Text = AppResources.AppBarButtonText;
        //    ApplicationBar.Buttons.Add(appBarButton);

        //    // Create a new menu item with the localized string from AppResources.
        //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
        //    ApplicationBar.MenuItems.Add(appBarMenuItem);
        //}
    }
}